package top.timous.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.timous.service.ProvinceService;

import java.util.HashMap;
import java.util.Map;

/**
 * province/ajax/noDataList?date=2020-11-16
 */
@Controller
@RequestMapping("/province")
public class ProvinceController {
    @Autowired
    private ProvinceService provinceService;

    @RequestMapping("/ajax/noDataList")
    @ResponseBody
    public Map<String , Object> noDataProvince(String date){
        System.out.println(date);
        if (!StringUtils.isEmpty(date)){   // 判断日期是不是为null
            //表示页面的日期是有效的   使用服务层的对象 ， 调用服务层的方法
            return provinceService.noDataProvinceList(date);
        }else{
            //页面没有提交一个日期类的字符串
            Map<String , Object> map = new HashMap<String, Object>();
            map.put("msg" , "请求日期的格式有问题！！");
            map.put("code" , "-1");
            return map;
        }
    }
}
